home *** CD-ROM | disk | FTP | other *** search
/ An Invitation to the Roland World of Music / Roland - An Invitation To The Roland World Of Music.bin / vb / cooltool / sysex / coolsysx.txt next >
Text File  |  1995-03-27  |  4KB  |  136 lines

  1. Basic concept for System Exclusive with MIDI CoolTools
  2. Copyright (C)1995, Artic Software
  3.  
  4. Artic Software
  5. PO Box 28
  6. Waterford, WI  53185-0028
  7.  
  8. =====================================================
  9.  
  10. ' ** SENDING SYSEX MESSAGES **
  11.  
  12. ' You need to open the MIDIOUT first.
  13. '
  14. MIDIOutput1.Action = MIDIOUT_OPEN
  15.  
  16. ' Define the Message Byte as the first byte. In the case of 
  17. ' sysex messages, it's always &HF0 
  18. '
  19. MIDIOutput1.Message = &HF0
  20.  
  21. ' Define the .Buffer property (string)  
  22. ' Use Chr$(&HF7) at the end of buffer string. 
  23. '
  24. ' This is what the message is based on - all in Hex:
  25. '
  26. ' F0      Start byte
  27. ' 0F      Manufacturer Code
  28. ' 03      Product Code
  29. ' 00      MIDI Channel
  30. '
  31. ' 11      Parameter Update command Code (Ensoniq Only)
  32. '
  33. ' 00 00 00 00 00
  34. ' 01      Instrument, Layer, Wavesample - all Ensoniq only)
  35. '
  36. ' 34      System Parameter
  37. ' 01      Master Tune Parameter 00 00 00
  38. ' 0F      This is the value to change the Master Tune to - +15
  39. '
  40. ' F7      End of message 
  41. '
  42. ' The following is the example message:
  43. '
  44. MIDIOutput1.Buffer = Chr$(&HF0) & Chr$(15) & Chr$(3) & Chr$(0) & 
  45. Chr$(3) & Chr$(0) & Chr$(InstNum) & Chr$(0) & Chr$(0) & Chr$(0) & 
  46. Chr$(1) & Chr$(&HF7) 
  47.  
  48. ' Set the Time (optional), 
  49. '
  50. MIDIOutput1.Time = 0
  51.  
  52. ' Place message into Queue and Start later
  53. '
  54. MIDIOutput1.Action = MIDIOUT_QUEUE
  55. MIDIOutput1.Action = MIDIOUT_START 
  56.  
  57. ' or send message immediately
  58. '
  59. MIDIOutput1.Action = MIDIOUT_SEND
  60.  
  61. =======================================================
  62.  
  63. ' ** RECEIVING SYSEX MESSAGES **
  64.  
  65. ' First, you need to open the MIDIIN.
  66. '
  67. MIDIInput1.Action = MIDIIN_OPEN
  68.  
  69.     
  70. 'Set the MIDIIn Port to Start
  71. '
  72. MIDIInput1.Action = MIDIIN_START
  73.  
  74. 'Set your code to be ready to capture the incoming text. 
  75. '
  76. '
  77. 'From inside the Sub MIDIInput1 Message event, this Do While Loop allows you to receive  
  78. 'sysex messages that are waiting in MIDIInput1.Buffer.  You will only find
  79. 'sysex messages in the MIDIInput Buffer.  To set the size of this buffer, you must do this
  80. 'at design time using the MaxSysexSize property of MIDIInput1.
  81. '
  82. 'A MIDI Message is waiting because MessageCount is > 0 and the length of the Buffer 
  83. 'is > 0 so there is a sysex message in this buffer.
  84. '
  85. Do While MIDIInput1.MessageCount > 0 And Len(MIDIInput1.Buffer) > 0
  86.    'A complete sysex message has been received into the
  87.    'MIDIInput.Buffer
  88.    '
  89.    'Now we'll put the first data byte of sysex message into
  90.    'the DisplayBufferString.
  91.    '   
  92.    DisplayBufferString = Hex(Asc(Left(MIDIInput1.Buffer, 1)))
  93.  
  94.    'Now we're going to go through the remaining portion of the
  95.    'sysex message and get it ready to display.  We'll then be able
  96.    'to view and edit the complete sysex message.
  97.    '
  98.    For n = 2 To Len(MIDIInput1.Buffer)
  99.        DisplayBufferString = DisplayBufferString & " " & Hex(Asc(Mid(MIDIInput1.Buffer, n, 1)))
  100.    Next n
  101.  
  102.    '
  103.    'DisplayBufferString now contains the sysex message in a viewable
  104.    'format
  105.    '
  106.    'Remove the MIDI data from the MIDI IN queue
  107.    '
  108.  
  109.    MIDIInput1.Action = MIDIIN_REMOVE
  110. Loop
  111.  
  112. 'DisplayBufferString now contains the sysex message in a viewable
  113. 'format. Now let see it.
  114.  
  115. Label1.Caption = DisplayBufferString
  116.  
  117.  
  118. ' IF the buffer is > 0 then we've received some sysex data
  119. If Len(DisplayBufferString(SysexListCount)) > 0 Then
  120.    MIDIOutput1.Message = MIDIInput1.Message
  121.    MIDIOutput1.Data1 = MIDIInput1.Data1
  122.    MIDIOutput1.Data2 = MIDIInput1.Data2
  123.    MIDIInput1.Action = MIDIIN_REMOVE
  124.    MIDIOutput1.Action = MIDIOUT_START
  125.    MIDIOutput1.Action = MIDIOUT_SEND
  126.    MIDIOutput1.Action = MIDIOUT_STOP
  127. End If
  128.  
  129.  
  130. ' When the program is exited, you need to close both the 
  131. ' MIDIIN and MIDIOUT.
  132. '
  133. MIDIOutput1.Action = MIDIOUT_CLOSE
  134. MIDIInput1.Action = MIDIIN_CLOSE
  135.  
  136.